
#include "BmpAnimateCtrl.h"
#include "../debug_new.h"

CBmpAnimateCtrl::CBmpAnimateCtrl()
{
	Init();
	m_nIconNum  = 0;
	m_nIndex    = 0;
	m_bPlay     = FALSE;
}

CBmpAnimateCtrl::CBmpAnimateCtrl(UINT nID):CBmpBtn(nID)
{
	Init();
	m_nIconNum  = 0;
	m_nIndex    = 0;
	m_bPlay     = FALSE;
}

CBmpAnimateCtrl::CBmpAnimateCtrl(wstring strCaption,UINT nID)
:	CBmpBtn(strCaption,nID)
{
	Init();
	m_nIconNum  = 0;
	m_nIndex    = 0;
	m_bPlay     = FALSE;
}

CBmpAnimateCtrl::CBmpAnimateCtrl(DWORD dwStyle,wstring strCaption, const CRect &rc, UINT nID)
:	CBmpBtn(dwStyle, strCaption,rc, nID)
{
	Init();
	m_nIconNum  = 0;
	m_nIndex    = 0;
	m_bPlay     = FALSE;
}

CBmpAnimateCtrl::CBmpAnimateCtrl(DWORD dwStyle, wstring strCaption, int x, int y, int cx, int cy, UINT nID)
:	CBmpBtn(dwStyle, strCaption, x, y, cx, cy, nID)
{
	Init();
	m_nIconNum  = 0;
	m_nIndex    = 0;
	m_bPlay     = FALSE;
}

CBmpAnimateCtrl::~CBmpAnimateCtrl()
{

}

void CBmpAnimateCtrl::Paint(CDC* pDC)
{
	if(m_rcControl.IsRectEmpty())
	{
		return ;
	}

	if(!IsVisible())
	{
		return;
	}

	if(!m_pImgLstBtn)
	{
		return;
	}

	if(m_bPlay)
	{
		m_nIndex++;
		if(m_nIndex > m_pImgLstBtn->GetImageCount() - 1)
		{
			m_nIndex = 0;
		}
		m_pImgLstBtn->Draw(pDC,m_nIndex,m_rcControl.TopLeft());
	}
	else
	{
		m_pImgLstBtn->Draw(pDC,0,m_rcControl.TopLeft());
	}
}